clear all
set mem 30m
set more off

use "/Users/gwf25/Dropbox/research/religion/final code/religion_all.dta"

//  Begin definition of variables

***Drop subjects who thought the experiment was about religion
gen id = _n
drop if id == 98 | id == 176 | id == 194 | id == 383

***Drop subjects who incorrectly completed the priming task. This includes subjects who leave more than half the responses blank. The following subjects
***all left at least questions #2-#7 blank in the sentence unscrambling task. 
drop if id==7 | id==719 | id==740 | id==762 | id==940

***An error led to some subjects seeing both the control and religion salient sentence unscrambling tasks. Here, we drop those subjects.
drop if prime_diff == 1

***"skipped" is a dummy variable for whether subjects skip the question that asks their religion. If they skip this question, we drop them from the sample 
***and if not, we assign a dummy variable to indicate the treatment group (religion salient or control) that subject belongs to.
gen skipped=0
replace skipped=1 if  s10q15==""
gen treatR=.
replace treatR=religion if skipped==0
drop if skipped==1

***Define religion
gen relig=.

***Note: 1 = protestant or other christian, 2 = catholic, 3 = jewish, 4 = agnostic/atheist
replace relig=1 if (s10q15=="Christian - Other (please specify below)" | s10q15=="Christian - Protestant (please specify denomination below)")
replace relig=2 if s10q15=="Christian - Catholic"
replace relig=3 if s10q15=="Jewish (Orthodox/Reformed/etc.)" | s10q15=="Jewish (Orthodox/Reform/etc.)"
replace relig=4 if (s10q15=="Agnostic" | s10q15=="Atheist")

***Drop Mormon/Othodox Christians from the sample
drop if s10q15sp == "Greek Orthodox"
drop if s10q15sp == "Russian Othrodox"
drop if s10q15sp == "greek orthodox"
drop if s10q15sp == "Orthodox Christian"
drop if s10q15sp == "Greek Orthdox"
drop if s10q15sp == "christian orthodox"
drop if s10q15sp == "Greek Orthodox Christian"
drop if s10q15sp == "Russian orthodox"
drop if s10q15sp == "Church of Jesus Christ of Latter Day Saints"
drop if s10q15sp == "Greek Orthodox"

// End of variables

drop if relig == .

*MALE
tab s10q8
gen male = .
replace male = 1 if s10q8 == "Male"
replace male = 0 if s10q8 == "Female"

su male if relig == 1
su male if relig == 2
su male if relig == 3
su male if relig == 4
su male

*BORN IN US
gen usa = .
replace usa = 0 if s10q13 ~= ""
replace usa = 1 if s10q13 == "America"
replace usa = 1 if s10q13 == "The U.S."
replace usa = 1 if s10q13 == "The United States"
replace usa = 1 if s10q13 == "The United States of America"
replace usa = 1 if s10q13 == "U.S"
replace usa = 1 if s10q13 == "U.S."
replace usa = 1 if s10q13 == "U.S.A"
replace usa = 1 if s10q13 == "U.S.A."
replace usa = 1 if s10q13 == "UNITED STATES"
replace usa = 1 if s10q13 == "US"
replace usa = 1 if s10q13 == "US of A"
replace usa = 1 if s10q13 == "US, but spent childhood elsewhere"
replace usa = 1 if s10q13 == "USA"
replace usa = 1 if s10q13 == "Uinted States"
replace usa = 1 if s10q13 == "United Staes"
replace usa = 1 if s10q13 == "United Staets"
replace usa = 1 if s10q13 == "United Statees of America"
replace usa = 1 if s10q13 == "United States"
replace usa = 1 if s10q13 == "United States of America"
replace usa = 1 if s10q13 == "`United States of America"
replace usa = 1 if s10q13 == "america"
replace usa = 1 if s10q13 == "the United States"
replace usa = 1 if s10q13 == "the united states"
replace usa = 1 if s10q13 == "this one"
replace usa = 1 if s10q13 == "u.s"
replace usa = 1 if s10q13 == "united States"
replace usa = 1 if s10q13 == "united states"
replace usa = 1 if s10q13 == "united states of america"
replace usa = 1 if s10q13 == "us"
replace usa = 1 if s10q13 == "usa"

su usa if relig == 1
su usa if relig == 2
su usa if relig == 3
su usa if relig == 4
su usa

*median income
gen incMedRel1 = .

tab s10q26
gen inc = .
replace inc = 1 if s10q26 == "Under $20,000"
replace inc = 2 if s10q26 == "Between $20,000 and $39,999"
replace inc = 3 if s10q26 == "Between $40,000 and $59,999"
replace inc = 4 if s10q26 == "Between $60,000 and $79,999"
replace inc = 5 if s10q26 == "Between $80,000 and $99,999"
replace inc = 6 if s10q26 == "Over $100,000"

su inc if relig == 1, detail 
su inc if relig == 2, detail 
su inc if relig == 3, detail 
su inc if relig == 4, detail 
su inc, detail 

*SAT Math
tab s10q27sp1
gen satM = s10q27sp1
replace satM = . if s10q27sp1 > 800
mean satM if relig == 1
mean satM if relig == 2
mean satM if relig == 3
mean satM if relig == 4
mean satM

*SAT Verbal
tab s10q27sp2
gen satV = s10q27sp2
replace satV = . if s10q27sp2 > 800
mean satV if relig == 1
mean satV if relig == 2
mean satV if relig == 3
mean satV if relig == 4
mean satV

*Religious service attendance
gen religserv_freq = .
replace religserv_freq = 1 if s10q16 == "Never"
replace religserv_freq = 2 if s10q16 == "Less than once a month"
replace religserv_freq = 3 if s10q16 == "Once a month"
replace religserv_freq = 4 if s10q16 == "A few times a month"
replace religserv_freq = 5 if s10q16 == "Once a week"
replace religserv_freq = 6 if s10q16 == "A few times a week"
replace religserv_freq = 7 if s10q16 == "Once a day"
replace religserv_freq = 8 if s10q16 == "More than once a day"

gen att = .
replace att = 1 if religserv_freq >= 5
replace att = 0 if religserv_freq < 5

su att if relig == 1
su att if relig == 2
su att if relig == 3
su att if relig == 4
su att

*pray at least once a day
tab s10q17
gen onc = .
replace onc = 0 if s10q17 ~= "" 
replace onc = 1 if s10q17 == "More than once a day" 
replace onc = 1 if s10q17 == "Once a day"
su onc if relig == 1
su onc if relig == 2
su onc if relig == 3
su onc if relig == 4
su onc

*N
count if relig == 1
count if relig == 2
count if relig == 3
count if relig == 4
count
